<?php 
	$this->headTitle ( 'Request Donation' );
?>
<script>
    dojo.require("dojox.form.FileUploader");
	
	
    dojo.addOnLoad(function(){

		var props = {
			isDebug:true,
			devmode:true,			
			hoverClass:"uploadHover",
			activeClass:"uploadPress",
			disabledClass:"uploadDisabled",
			uploadUrl:"<?php echo $this->linkTo('upload','index','frontend');?>",
			fileMask:[
				["Jpeg File", 	"*.jpg;*.jpeg"],
				["GIF File", 	"*.gif"],
				["PNG File", 	"*.png"],
				["All Images", 	"*.jpg;*.jpeg;*.gif;*.png"]
			]
		}
		
		if(dojo.byId("btnF")){
			dojo.byId("Files").value = ""; 
			var uploader = new dojox.form.FileUploader(dojo.mixin({
				fileListId:"Files",
				tabIndex:9,
				uploadOnChange:true,
				selectMultipleFiles:false,
				deferredUploading:false
			},props), "btnF");				

			dojo.connect(uploader, "onComplete", function(dataArray){				
				dojo.forEach(dataArray, function(d){
					alert('Photo upload finished');
					dojo.byId("filename").value = d.name;
				});
			});
		
		}	
		
		if(dijit.byId("btnD")){
			var d = new FlashHTML.widget(dojo.mixin({button:dijit.byId("btnD")}, props));
			d.attr("disabled", dojo.byId("dTitle").value=="");			
			dojo.connect(dijit.byId("fSubmit"), "onClick", function(evt){
				uploader.submit(dojo.byId("formF"));
				dojo.stopEvent(evt);
			});
		}
	});
</script>

<div id="form-container">
<h2>Request Donation</h2>
<br />
<?php if (!empty($this->formError)): ?>
<div class="form_errors_block">
	<img src="<?php echo $this->linkTo(null,null); ?>images/icons/error.png" alt=""/>
	<p class="message"><?php echo $this->formError; ?></p>
</div>
<?php endif; ?>
<?php if (!empty($this->formSucces)): ?>
<div class="form_succes_block">
	<img src="<?php echo $this->linkTo(null,null); ?>images/icons/succes.png" alt=""/>
	<p class="message"><?php echo $this->formSucces; ?></p>
</div>
<?php endif; ?>

<?php  
	$donation = Doctrine::getTable("Donations")->findOneById_user($this->UserInfo('userId'));
?>
<?php if ($donation): ?>
	<?php echo $this->form; ?>
<?php else: ?>
	<p>&quot;Oops, seems like you are new to this! You can request a donation but you must have
	contributed at last a little something before. That&lsquo;s the spirit of our community, and it&lsquo;s
	based on the fairness principle. Give a little &ndash; get a little &ndash; or even a little much more.
	Therefore, you must contribute at the very least $1 before you can submit a request for
	a donation.&quot;</p> 
	<p>Click <a href="<?php echo $this->linkTo('donate','donation'); ?>" >here</a> to <a href="<?php echo $this->linkTo('donate','donation'); ?>" >Donate now</a>.</p>
<?php endif; ?>
</div>